// 封装消息框
//导入消息框组件

// 成功的消息框
import { ElMessage, ElMessageBox } from 'element-plus'
export let msg_s = (message, duration = 2000) => {
    ElMessage({
        message: message,
        type: 'success',
    })
}

//警告消息框
export let msg_w = (message, duration = 2000) => {
    ElMessage({
        message: message,
        type: 'warning',
    })
}

//消息提示框
export let msg_m = (message, duration = 2000) => {
    ElMessage(message)
}

//错误消息框
export let msg_e = (message, duration = 2000) => {
    ElMessage.error(message)
}

//对后端返回值显示提示框信息

export let displayBoxInfo = (code, msg) => {
if (code == 1) {
        msg_s(msg)
    } else if (code == 0) {
        msg_w(msg)
    }
    else {
        msg_e("系统异常，请联系管理员")
    }

}

//确认框
export let $confirm = (message, type = "Warning", title = "提示") => {
    return new Promise((resolve, reject) => {
        ElMessageBox.confirm(
            message,
            title,
            {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type,
            }
        )
            .then(() => {
                resolve()
            })
            .catch(() => {
            })
    })
}

